home *** CD-ROM | disk | FTP | other *** search
- class Hint
- {
- var _visible;
- static var hints;
- static var mc;
- static var active = true;
- function Hint(fa, fc, lc, fmt)
- {
- if(Hint.hints)
- {
- delete this;
- return undefined;
- }
- Hint.hints = [];
- Hint.mc = _root.createEmptyMovieClip("hints_mc",16383);
- Hint.mc.createTextField("tf",0,0,0,0,0);
- Hint.mc.tf.autoSize = true;
- Hint.mc.tf.selectable = false;
- Hint.mc.lc = lc != undefined ? lc : 3355443;
- Hint.mc.fc = fc != undefined ? fc : 16777164;
- Hint.mc.fa = fa != undefined ? fa : 100;
- Hint.mc.fmt = new TextFormat("_sans",10,3355443);
- for(var i in fmt)
- {
- Hint.mc.fmt[i] = fmt[i];
- }
- TextField.prototype.addHint = Button.prototype.addHint = MovieClip.prototype.addHint = function(t)
- {
- var _loc2_ = Hint.hints.length;
- do
- {
- _loc2_;
- if(!_loc2_--)
- {
- break;
- }
- }
- while(Hint.hints[_loc2_].o != this);
-
- if(t != undefined)
- {
- var _loc3_ = Hint.hints[_loc2_];
- if(!_loc3_)
- {
- var _loc0_ = null;
- _loc3_ = Hint.hints[Hint.hints.length] = {o:this,txt:t};
- }
- }
- else if(Hint.hints[_loc2_])
- {
- Hint.hints.splice(_loc2_,1);
- }
- Hint.mc.onMouseMove();
- };
- var isParent = function(a, b)
- {
- while((a = a._parent) != _root)
- {
- if(a == b)
- {
- return true;
- }
- }
- return false;
- };
- var getParentDepth = function(a, p)
- {
- while(a._parent != p)
- {
- a = a._parent;
- }
- return a.getDepth();
- };
- var getGeneric = function(a, b)
- {
- while(!isParent(a,b) && b != _root)
- {
- b = b._parent;
- }
- return b;
- };
- var order = function(a, b)
- {
- if(isParent(a.o,b.o))
- {
- return -1;
- }
- if(isParent(b.o,a.o))
- {
- return 1;
- }
- var _loc3_ = getGeneric(a.o,b.o);
- return getParentDepth(a.o,_loc3_) < getParentDepth(b.o,_loc3_);
- };
- Hint.mc.onMouseMove = function()
- {
- this._visible = false;
- if(!Hint.active)
- {
- return undefined;
- }
- if(!_root.hitTest(_xmouse,_ymouse,true))
- {
- return undefined;
- }
- var dbl = [];
- for(var i in Hint.hints)
- {
- var o = Hint.hints[i].o;
- if(o._x == undefined)
- {
- Hint.hints.splice(Number(i),1);
- }
- else if(o._visible && _root.hitTest.call(o,_xmouse,_ymouse,true))
- {
- dbl.push(Hint.hints[i]);
- }
- }
- switch(dbl.length)
- {
- case 0:
- return undefined;
- case 1:
- var up = dbl[0];
- break;
- default:
- var up = dbl.sort(order)[0];
- }
- with(this)
- {
- if(hint != up)
- {
- by = _loc0_ = null;
- bx = _loc0_;
- }
- hint = up;
- _visible = _loc0_ = true;
- _loc0_;
- _x = _loc0_ = _root._xmouse;
- _loc0_;
- _y = _loc0_ = _root._ymouse;
- _loc0_;
- var x = _x + _width < Stage.width;
- var y = _y - _height < 0;
- if(bx != x)
- {
- bx = x;
- if(by == y)
- {
- drawHint();
- }
- }
- if(by != y)
- {
- by = _loc0_ = y;
- _loc0_;
- drawHint();
- }
- }
- updateAfterEvent();
- };
- Hint.mc.drawHint = function()
- {
- var dr = 8;
- with(this)
- {
- tf.text = hint.txt;
- tf.setTextFormat(fmt);
- var w = tf._width;
- var h = tf._height;
- var sx = tf._x = !bx ? - w - dr : dr;
- var sy = tf._y = !by ? - h - dr : dr;
- clear();
- var i = 5;
- var n = 8;
- while(i--)
- {
- beginFill(0,3);
- var ux = sx + n - i;
- var lx = sx + w + i;
- var uy = sy + n - i;
- var ly = sy + h + i;
- var r = n - i;
- var f = 0.707106781186548 * r;
- var a = 0.588186525863094 * r;
- var b = 0.00579432557070009 * r;
- var cx = lx - r;
- var cy = uy + r;
- moveTo(ux + r,uy);
- lineTo(cx,uy);
- curveTo(lx - a,uy + b,cx + f,cy - f);
- curveTo(lx - b,uy + a,lx,uy + r);
- cy = ly - r;
- lineTo(lx,cy);
- curveTo(lx - b,ly - a,cx + f,cy + f);
- curveTo(lx - a,ly - b,lx - r,ly);
- cx = ux + r;
- lineTo(cx,ly);
- curveTo(ux + a,ly - b,cx - f,cy + f);
- curveTo(ux - b,ly - a,ux,ly - r);
- cy = uy + r;
- lineTo(ux,cy);
- curveTo(ux + b,uy + a,cx - f,cy - f);
- curveTo(ux + a,uy + b,ux + r,uy);
- endFill();
- }
- lineStyle(0,lc,50);
- beginFill(fc,fa);
- moveTo(sx,sy);
- lineTo(sx + w,sy);
- lineTo(sx + w,sy + h);
- lineTo(sx,sy + h);
- lineTo(sx,sy);
- endFill();
- }
- updateAfterEvent();
- };
- }
- }
-